package com.kevin.enterprise.utils;

import java.sql.*;

public class JdbcUtils {

    public  static Connection getConnection() throws  Exception{
        //Class.forName("com.mysql.jdbc.Driver");
        Class.forName("oracle.jdbc.driver.OracleDriver");

        //2.创建连接
        /*String url = "jdbc:mysql://localhost:3306/test";
        String user = "root";
        String password = "admin";*/
        String url="jdbc:oracle:thin:@localhost:1521:orcl";
        String user="scott";
        String password="oracle";
        Connection conn = DriverManager.getConnection(url, user, password);
        return  conn;
    }

    public static  void getClose(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet){
        try {
            if (resultSet!=null){
                resultSet.close();
            }
            if (preparedStatement!=null){
                preparedStatement.close();
            }
            if (connection!=null){
                connection.commit();
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
